unit UnLogin;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls,UndataModule;

type
  TLogin = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Login: TButton;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    procedure FormCanResize(Sender: TObject; var NewWidth, NewHeight: Integer;
      var Resize: Boolean);
    procedure LoginClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Edit2KeyPress(Sender: TObject; var Key: Char);
  private
    procedure DoLogin;
  public
    { Public declarations }
  end;

var
  Login: TLogin;

implementation

{$R *.dfm}

uses UnMain;

procedure TLogin.Edit2KeyPress(Sender: TObject; var Key: Char);
begin
  if Key = #13 then
  DoLogin;
end;

procedure TLogin.FormCanResize(Sender: TObject; var NewWidth,
  NewHeight: Integer; var Resize: Boolean);
begin
  NewWidth := Width;
  NewHeight := Height;
end;

procedure TLogin.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action := caFree;
end;

procedure TLogin.LoginClick(Sender: TObject);
begin
  DoLogin;
end;

procedure TLogin.DoLogin;
begin
  if TMain(Self.Owner).beheerder.Login(Edit1.Text,Edit2.Text,TMain(Self.Owner).aStatusLijst) = true then
  begin
    Label3.Visible := false;
    TMain(Self.Owner).enableMenu;
    Close;
  end
  else
  begin
    Label3.Visible := true;
    Edit1.Clear;
    Edit2.Clear;
    Edit1.SetFocus;
  end;
end;

end.
